// 防抖立即执行版
export default function debounce(fn, time) {
    let timer = null
    return function() {
        let context = this
        let args = arguments
        if (timer) clearTimeout(timer)  //清除前一个定时器
        let callNow = !timer
        timer = setTimeout(() => {
            timer = null
        }, time || 500)
        if (callNow) fn.apply(context, args)
    }
}